<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const nums = {
        1: 2,
        2: -11,
        3: 4,
        4: 1,
      };

      // 统计属性个数
      let len = 0;
      for (let k in nums) {
        len++;
      }

      const newMums = {};
      for (let i = 1; i <= len; i++) {
        let k;
        let v = Infinity;
        for (let i in nums) {
          if (v > nums[i]) {
            v = nums[i];
            k = i;
          }
        }
        newMums[i] = v;
        delete nums[k];
      }
      console.log(newMums);
    </script>
  </body>
</html>
